<template>
	<view class="u-page">
		<u-subsection :list="date" :current="current" @change="sectionChange"></u-subsection>
		<view v-for="(item, index) in list" :key="index">
			<u-cell customStyle="background:#fff;" :value="'￥'+item.money" :title="item.createtime" :label="item.remark"></u-cell>
		</view>
		<u-empty v-if="list.length==0" text="没有收益!" mode="search" marginTop="60"></u-empty>
		<view v-if="list.length>0" class="footer">
			<view class="heji">合计：{{total}}</view>
		</view>
	</view>
</template>

<script>
	import {methods} from '@/utils/methods.js';
	export default {
		data() {
			return {
				seller_id:'',
				date:['全部','今年','上月','当月','本周','昨天','今天'],
				current:3,
				list:[],
				page:1,
				endData:false,
				total:''
			}
		},
		onPullDownRefresh() {
			this.list=[];
			this.page=1;
			this.endData=false;
			this.pagelist(true);
		},
		onReachBottom() {
			this.pagelist();
		},
		onLoad(e) {
			this.seller_id=e.seller_id || '';
			this.pagelist();
		},
		methods: {
			...methods,
			sectionChange:function(e){
				this.current=e;
				this.list=[];
				this.page=1;
				this.endData=false;
				this.pagelist();
			},
			pagelist:function(pulldown){
				if(this.endData){
					this.$msg('已经到底了');
					return;
				}
				let dates=['all','year','last-month','this-month','this-week','yestoday','today'];
				this.$get("admin/seller/shouyi",{
					page:this.page,
					seller_id:this.seller_id,
					date:dates[this.current]
				},true).then(res=>{
					if(pulldown){
						uni.stopPullDownRefresh();
					}
					if(res.length<10){
						this.endData=true;
					}
					this.list=this.list.concat(res.list);					
					this.total=res.total;
					this.page++;
				});		
			}
		}
	} 
</script>

<style lang="scss">
	.u-page{
		padding-bottom: 100rpx;
	}
	.footer{
		background-color: #fff;
		position: fixed;
		bottom: 0rpx;
		height: 100rpx;
		width: 100%;
		border-top: 4rpx solid #dddddd;
		font-size: 20rpx;
		.heji{
			padding: 10rpx 20rpx;
		}
	}
</style>